package com.javacoo.xservice.base.support.security.internal;

import com.javacoo.xservice.base.security.util.SignUtil;
import com.javacoo.xservice.base.support.security.SignBean;
import com.javacoo.xservice.base.support.security.SignService;

/**
 * 默认签名服务
 * <li></li>
 *
 * @author: duanyong@jccfc.com
 * @since: 2021/4/15 18:32
 */
public class DefaultSignService implements SignService {

    /**
     * 校验签名
     * <li></li>
     *
     * @param verifySignBean : 待校验签名对象
     * @author duanyong@jccfc.com
     * @date 2021/4/15 18:31
     * @return: boolean
     */
    @Override
    public boolean verifySign(SignBean verifySignBean) {
        return SignUtil.cloudVerifySign(verifySignBean.getSign(),
            verifySignBean.getParam(),
            verifySignBean.getNonce(),
            verifySignBean.getTimestamp(),
            verifySignBean.getSecretkey());
    }

    /**
     * 签名
     * <li></li>
     *
     * @param signBean : 待签名对象
     * @author duanyong@jccfc.com
     * @date 2021/4/15 18:31
     * @return: java.lang.String 签名字符串
     */
    @Override
    public String sign(SignBean signBean) {
        return SignUtil.clientSign(signBean.getParam(),signBean.getNonce(),signBean.getTimestamp(),signBean.getSecretkey());
    }
}
